class Solution(object):
    def getRow(self, rowIndex):
        lastRow = []
        for length in range(1, rowIndex+2):
            row = [0 for _ in range(length)]
            row[0]=1
            row[-1]=1
            for i in range(1, length-1):
                row[i] = lastRow[i]+lastRow[i-1]
            lastRow = row
        return lastRow

print(Solution().getRow(3))